using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Buff8 : PlayerControllerBuffBase
{
    float m_Timer = 0;

    float m_HealthRegenerationPerSecond = 100;
    float m_HealCountPerSecond = 10;
    float m_HealValue;
    float m_HealInterval;


    public override string GetDescription()
    {
        return $"每秒恢复{m_HealthRegenerationPerSecond}点生命值。";
    }

    public override void AfterBeAdded()
    {
        m_HealValue = m_HealthRegenerationPerSecond / m_HealCountPerSecond;
        m_HealInterval = 1 / m_HealCountPerSecond;
    }
    public override void FixedUpdate()
    {
        m_Timer += Time.fixedDeltaTime;
        if (m_Timer >= m_HealInterval)
        {
            m_Timer -= m_HealInterval;
            Owner.CurrentHealth += m_HealValue;
        }
    }
    protected override void OnCurrentLevelChange(int change)
    {
        if (change == 0 && CurrentLevel == BuffData.maxLevel)
        {
            ResidualDuration = BuffData.maxDuration;
        }
    }
}
